This is an interactive notebook. You can run it locally or use the links below:
Setting up a custom cost model
Weave calculates costs based on the number of tokens used and the model used. Weave grabs this usage and model from the output and associates them with the call. Let’s set up a simple custom model, that calculates its own token usage, and stores that in weave.Set up the environment
We install and import all needed packages. We setWANDB_API_KEY
in our env so that we may easily login with wandb.login()
(this should be given to the colab as a secret).
We set the project in W&B we want to log this into in name_of_wandb_project
.
NOTE: name_of_wandb_project
may also be in the format of {team_name}/{project_name}
to specify a team to log the traces into.
We then fetch a weave client by calling weave.init()
Setting up a model with weave
Add a custom cost
Here we add a custom cost, and now that we have a custom cost, and our calls have usage, we can fetch the calls withinclude_cost
and our calls with have costs under summary.weave.costs
.